layui.use(['jquery', 'layer', 'form', 'table', 'laydate', 'element'], function () {
    var $ = layui.jquery;
    var laydate = layui.laydate;

    laydate.render({
        elem: '#year',
        type: 'year',
        value: new Date()
    });
    $("#doSearch").click(function () {
        getData();
    });

    function getData() {
        var year = $("#year").val();
        if (year === "") {
            year = new Date().getFullYear();
        }
        $.post("/statistics/reportYearFinance", {year: year}, function (data) {

            //alert(data);

            var dom = document.getElementById("container");
            var myChart = echarts.init(dom);
            var app = {};
            option = null;
            option = {
                title: {
                    text: '医院年度额统计',
                    x: 'center'
                },
                tooltip: {
                    trigger: 'axis',
                    axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                        type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                    }
                },
                xAxis: {
                    type: 'category',
                    data: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月']
                },
                yAxis: {
                    type: 'value'
                },
                series: [{
                    data: data,
                    type: 'line'
                }]
            };
            ;
            if (option && typeof option === "object") {
                myChart.setOption(option, true);
            }
        });
    }

    getData();
})